﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using PGMHelper;
using WHelper = PGMHelper.WilsonHelper;
using Spectrum;

namespace SpectrumTestForm
{
    public partial class BlineCorrectForm : Form
    {
        /// <summary>
        /// 加速度时程曲线
        /// </summary>
        private AccelSet Accels { set; get; }

        public BlineCorrectForm()
        {
            InitializeComponent();
        }

        private void TestButton_Click(object sender, EventArgs e)
        {
            //初始化
            string filePath = string.Empty;
            //获得文件路径
            if (!WHelper.OpenFile("所有文件(*.*)|*.*", ref filePath))
                return;
            //构造加速度 跳过8行 用","拆分
            this.Accels = new AccelSet(filePath, 1, 1, 0.01F);
            //var MIV = this.Accels.MaxIncrementalValue(MotionEnum.Accel);
            //var MID = this.Accels.MaxIncrementalValue(MotionEnum.Vel);
            //构造反应谱求解器
            var spectrumAlogrithm = new SpectrumMethodParams(this.Accels, 0.05F, 6F, 0.01F, 0.01F);
            //清空Newmark参数
            spectrumAlogrithm.ClearNewMark();
            //求得反应谱
            var Spectrum = spectrumAlogrithm.GetSpectParam(true, 50);
            var afaMax = Spectrum.AfaMax;

            //绘制曲线
            this.Accels.ToChart(this.AccelChart, MotionEnum.Accel);
            this.Accels.ToChart(this.VelChart, MotionEnum.Vel);
            this.Accels.ToChart(this.DispChart, MotionEnum.Disp);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Accels.BaseLineCorrection();
            //绘制曲线
            this.Accels.ToChart(this.AccelChart, MotionEnum.Accel);
            this.Accels.ToChart(this.VelChart, MotionEnum.Vel);
            this.Accels.ToChart(this.DispChart, MotionEnum.Disp);
        }
    }
}
